package com.llap.exp190929.repository;

import com.llap.exp190929.entity.CardAccount;
import com.llap.exp190929.entity.TransactionRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public interface TransactionRecordRepository extends JpaRepository<TransactionRecord, Integer> {
    Page<TransactionRecord> findAllByAccountAndExpenseIsNotNull(CardAccount cardAccount, Pageable pageable);
    Page<TransactionRecord> findAllByAccountAndIncomeIsNotNull(CardAccount cardAccount, Pageable pageable);
    Page<TransactionRecord> findAllByAccount(CardAccount cardAccount, Pageable pageable);
    Page<TransactionRecord> findAllByAccountAndTransactionDateBetweenAndExpenseIsNotNull(CardAccount cardAccount, Date from, Date to, Pageable pageable);
    Page<TransactionRecord> findAllByAccountAndTransactionDateBetweenAndIncomeIsNotNull(CardAccount cardAccount, Date from, Date to, Pageable pageable);
    Page<TransactionRecord> findAllByAccountAndTransactionDateBetween(CardAccount cardAccount, Date from, Date to, Pageable pageable);
}
